package cn.tedu.buycradserver.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebFilter(filterName = "MyFilter",urlPatterns = {"/insertProduct.html","/insertBanner.html"})
public class AlbumFilter implements Filter {
    public void init(FilterConfig config) throws ServletException {
    }

    public void destroy() {
    }

    @Override //此方法是在请求到资源之前和之后调用的方法
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        //因为要使用子类型中的方法所以需要将父类类型转换
        HttpServletRequest ht = (HttpServletRequest)request;
        HttpServletResponse hs = (HttpServletResponse)response;
        chain.doFilter(request, response);//代表运行执行请求的资源
    }
}
